var $cxCardList = $('.cx-card-list');
var $cxBasicMsg = $('#cx-basic-msg');
var $cxDetailsMsg = $('#cx-details-msg');
var $cxCheckMsg = $('#cx-check-msg');
var $cxBasicList = $('#cxBasicList');
var $cxDetailsList = $('#cxDetailsList');
var $cxCheckList = $('#cxCheckList');
var $cxCheckCard = $('.cx-check-card');

$cxBasicMsg.on("tap", function() {
	$cxDetailsMsg.removeClass('active');
	$cxCheckMsg.removeClass('active');
	$cxBasicMsg.addClass('active');
	$cxCardList.addClass('hidden');
	$cxBasicList.removeClass('hidden');

});

$cxDetailsMsg.on("tap", function() {
	$cxBasicMsg.removeClass('active');
	$cxCheckMsg.removeClass('active');
	$cxDetailsMsg.addClass('active');
	$cxCardList.addClass('hidden');
	$cxDetailsList.removeClass('hidden');
});

$cxCheckMsg.on("tap", function() {
	$cxBasicMsg.removeClass('active');
	$cxDetailsMsg.removeClass('active');
	$cxCheckMsg.addClass('active');
	$cxCardList.addClass('hidden');
	$cxCheckList.removeClass('hidden');
});

$cxCheckCard.on("tap", function(e) {
	if(e.target.type === 'checkbox') {
		return;
	}
	var checkInput = $(e.currentTarget).find('input');
	var isChecked = checkInput.prop('checked');
	if(isChecked) {
		checkInput.removeAttr('checked');
	} else {
		checkInput.prop('checked', 'checked');
	}
});

//上拉加载更多,下拉刷新
refresher.init({
	id: "cxBasicList",
	pullDownAction: Refresh,
	pullUpAction: Load
});

function Refresh() {
	setTimeout(function() { // <-- Simulate network congestion, remove setTimeout from production!
		var el, li, i;
		el = document.querySelector("#cxBasicList ul");
		//这里写你的刷新代码				
		document.getElementById("cxBasicList").querySelector(".pullDownIcon").style.display = "none";
		document.getElementById("cxBasicList").querySelector(".pullDownLabel").innerHTML = "<img src='images/ok.png'/>刷新成功";
		setTimeout(function() {
			cxBasicList.refresh();
			document.getElementById("cxBasicList").querySelector(".pullDownLabel").innerHTML = "";
		}, 1000); //模拟qq下拉刷新显示成功效果
		/****remember to refresh after  action completed！ ---yourId.refresh(); ----| ****/
	}, 1000);
}

function Load() {
	setTimeout(function() { // <-- Simulate network congestion, remove setTimeout from production!
		console.log('加载中。。。。');
//		var el, li, i;
//		el = document.querySelector("#cxBasicList ul");
//		for(i = 0; i < 2; i++) {
//			li = document.createElement('li');
//			li.innerHTML = "<img src='imgages/game8.png'><div class='game-info'><h1>华仔超神战记</h1><p>9万次下载     89.18M</p><p>秒杀虚拟摇杆，砸烂手机键盘</p></div>"
//			el.appendChild(li, el.childNodes[0]);
//		}
		cxBasicList.refresh(); /****remember to refresh after action completed！！！   ---id.refresh(); --- ****/
	}, 2000);
}

////上拉加载更多,下拉刷新
//refresher.init({
//	id: "cxDetailsList",
//	pullDownAction: Refresh,
//	pullUpAction: Load
//});
//
//function Refresh() {
//	setTimeout(function() { // <-- Simulate network congestion, remove setTimeout from production!
//		var el, li, i;
//		el = document.querySelector("#cxDetailsList ul");
//		//这里写你的刷新代码				
//		document.getElementById("cxDetailsList").querySelector(".pullDownIcon").style.display = "none";
//		document.getElementById("cxDetailsList").querySelector(".pullDownLabel").innerHTML = "<img src='images/ok.png'/>刷新成功";
//		setTimeout(function() {
//			cxDetailsList.refresh();
//			document.getElementById("cxDetailsList").querySelector(".pullDownLabel").innerHTML = "";
//		}, 1000); //模拟qq下拉刷新显示成功效果
//		/****remember to refresh after  action completed！ ---yourId.refresh(); ----| ****/
//	}, 1000);
//}
//
//function Load() {
//	setTimeout(function() { // <-- Simulate network congestion, remove setTimeout from production!
//		console.log('加载中。。。。');
//		//		var el, li, i;
//		//		el = document.querySelector("#cxDetailsList ul");
//		//		for(i = 0; i < 2; i++) {
//		//			li = document.createElement('li');
//		//			li.innerHTML = "<img src='imgages/game8.png'><div class='game-info'><h1>华仔超神战记</h1><p>9万次下载     89.18M</p><p>秒杀虚拟摇杆，砸烂手机键盘</p></div>"
//		//			el.appendChild(li, el.childNodes[0]);
//		//		}
//		cxBasicList.refresh(); /****remember to refresh after action completed！！！   ---id.refresh(); --- ****/
//	}, 2000);
//}